package com.ffmpeg.util.api.controller;

import javax.servlet.http.HttpServletResponse;

import com.ffmpeg.util.app.FfmpegService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author : wm
 * @description : 测试Controller
 */
@RestController("v1.ffmpegController")
@RequestMapping("/v1/ffmpeg")
public class FfmpegController {
    private final FfmpegService ffmpegService;

    @Autowired
    public FfmpegController(FfmpegService ffmpegService) {
        this.ffmpegService = ffmpegService;
    }

    @PostMapping(value = "/compress")
    public void compressedVideo(@RequestBody MultipartFile file) {
        ffmpegService.compressedVideoByFile(file, false);
    }

    @PostMapping(value = "/compress-download")
    public void compressedVideoAndDownLoad(@RequestBody MultipartFile file, HttpServletResponse response) {
        ffmpegService.compressedVideoByFileAndDownload(file, response);
    }


    @GetMapping(value = "/hello")
    public String sayHello() {
        return "hello";
    }
}
